from flask_restful import Resource, reqparse
from flask import request
from app.api.services.service_source_path import ServiceSourcePath
from . import checkoutArgs


class ApiSourcePathList(Resource):
    def __init__(self):
        self.reqparse = reqparse.RequestParser()
        super(ApiSourcePathList, self).__init__()

    def get(self):
        return ServiceSourcePath().list_source_path()


class ApiSourcePathUpdate(Resource):
    def __init__(self):
        self.reqparse = reqparse.RequestParser()
        self.reqparse.add_argument(
            'path', type=str, required=True, help='path素材路径传输错误')
        super(ApiSourcePathUpdate, self).__init__()

    def post(self):
        args = self.reqparse.parse_args(strict=True)
        args_filter = checkoutArgs(args)
        return ServiceSourcePath().update_source_path(**args_filter)


class ApiSourcePackageList(Resource):
    def __init__(self):
        self.reqparse = reqparse.RequestParser()
        super(ApiSourcePackageList, self).__init__()

    def get(self):
        return ServiceSourcePath().list_source_package()
